package org.aplombh.java.interview.newcoder;

import java.util.Scanner;

public class HJ5_进制转换 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String a = in.nextLine();
            String sub = a.substring(2);
            int sum = 0;
            for (int i = 0; i < sub.length(); i++) {
                char b = sub.charAt(i);
                sum *= 16;
                if (b >= 'A' && b <= 'F') {
                    sum += (b - 'A' + 10);
                }else {
                    sum += (b - '0');
                }
            }
            System.out.println(sum);
        }
    }
}